package com.argrace.smart.callback;

import android.content.Context;
import android.util.Log;

import com.lzy.okgo.callback.AbsCallback;
import com.lzy.okgo.convert.StringConvert;
import com.lzy.okgo.request.BaseRequest;

import okhttp3.Call;
import okhttp3.Response;

/**
 * ================================================
 * 作    者：廖子尧
 * 版    本：1.0
 * 创建日期：2016/9/11
 * 描    述：返回字符串类型的数据
 * 修订历史：
 * ================================================
 */
public abstract class StringCallback extends AbsCallback<String> {

    private Context context;
    private boolean isToastShow;

    @Override
    public void onBefore(BaseRequest request) {

        context = (Context) request.getTag();

    }


    @Override
    public void onError(Call call, Response response, Exception e) {
        super.onError(call, response, e);

    }


    @Override
    public String convertSuccess(Response response) throws Exception {
        String s = StringConvert.create().convertSuccess(response);
        response.close();
//        JSONObject jsonObject = new JSONObject(s);
//        String retCode = jsonObject.getString("retCode");
//        String msg = jsonObject.getString("msg");
//        String body = jsonObject.getString("body");
//        if ("0".equals(retCode)) {
        return s;
//        } else {
//            throw new IllegalStateException(msg);
//        }
    }
}